using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter12
{
	/// <summary>
	/// Example05: Negotiating a Curb
	/// (A) Estimate the magnitude of the force F a 
	/// person must apply to a wheelchair's main wheel to roll 
	/// up over a sidewalk curb (Fig. 12.12a). This main wheel 
	/// that comes in contact with the curb has a radius r, 
	/// and the height of the curb is h. 
	/// F = 3 \times 10^2 N
	/// (B) Determine the magnitude and direction of R.
	/// \theta = 70^{\circle}
	/// R = 800 N 
	/// </summary>
	public class Example05
	{
		public Example05()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m = new L.Mass();
			m.kg = 70.0;
			L.Length ra = new L.Length();
			ra.m = 0.3;
			L.Length h = new L.Length();
			h.m = 0.1;
			double g = L.Constant.AccelerationOfGravity;

			L.Force[] f = new L.Force[3];
			L.Position[] r = new L.Position[3];

			f[0] = new L.Force();  // R
			f[0].XVariableQ = true;
			f[0].YVariableQ = true;
			f[1] = new L.Force();  // F
			f[1].XVariableQ = true;
			f[2] = new L.Force();  // mg
			f[2].Y = -m.kg*g;
						
			r[0] = new L.Position();
			r[1] = new L.Position();
			r[1].X = -Math.Sqrt(2.0*ra.m*h.m - h.m*h.m);
			r[1].Y = 2.0*ra.m - h.m;
			r[2] = new L.Position();
			r[2].X = -Math.Sqrt(2.0*ra.m*h.m - h.m*h.m);
			r[2].Y = ra.m - h.m;
			
			L.RigidBody ladder = new L.RigidBody();
			ladder.SolveStaticEquilibrium(r,f);
			
			result+=Convert.ToString(f[1].X)+"\r\n";
			result+=Convert.ToString(f[0].X)+"\r\n";
			result+=Convert.ToString(f[0].N)+"\r\n";
			result+=Convert.ToString(Math.Atan(f[0].Y/f[0].X)/Math.PI*180.0)+"\r\n";
		}
	}
}
